package com.qing.lambda;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Demo {

    public static String processFile(){
        try (
                BufferedReader bufferedReader=new BufferedReader(new FileReader("data.txt"));
                ){
            //做有用工作的哪行代码
          return   bufferedReader.readLine();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    };


    public static String processFile(BufferedReaderProcessor br){
        try (
                BufferedReader bufferedReader=new BufferedReader(new FileReader("data.txt"));
        ){

            //处理bufferedReader对象
            return   br.process(bufferedReader);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    };

    public static void main(String[] args) {
        String twoLines=processFile((BufferedReader br)->br.readLine()+br.readLine());
        System.out.println(twoLines);
    }

}
